#region License
//-----------------------------------------------------------------------------
// Copyright (c) 2008, Aaron MacDougall, Daniel Jeffery
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
//   this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
//   this list of conditions and the following disclaimer in the documentation
//   and/or other materials provided with the distribution.
//
// * Neither the name of Aaron MacDougall or Daniel Jeffery nor the names of its contributors may
//   be used to endorse or promote products derived from this software without
//   specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
#endregion

namespace Agro2D
{
    /// <summary>
    /// A simple class that contains most attributes of a Sprite. This allows
    /// for the Sprite attributes (this class) to be passed around without
    /// other classes knowing about Sprite itself. Mainly used by IAnimation.
    /// </summary>
    public class SpriteProperties : ICloneable
    {
        #region Fields
        /// <summary>
        /// Texture used to draw the Sprite.
        /// </summary>
        private TextureReference texture;
        /// <summary>
        /// Position in the world.
        /// </summary>
        private Vector2 position;
        /// <summary>
        /// Location of current frame on the source texture.
        /// </summary>
        private Rectangle sourceRectangle;
        /// <summary>
        /// Color tint of the Sprite.
        /// </summary>
        private Color tint;
        /// <summary>
        /// Rotation of the Sprite.
        /// </summary>
        private float rotation;
        /// <summary>
        /// Scale to draw the Sprite.
        /// </summary>
        private float scale;
        /// <summary>
        /// Sprite flipping directions.
        /// </summary>
        private SpriteEffects spriteEffect;
        /// <summary>
        /// Is the Sprite to be drawn?
        /// </summary>
        private bool isVisible;
        #endregion

        #region Constructors/Destructors
        /// <summary>
        /// Default Constructor.
        /// </summary>
        public SpriteProperties()
        {
            this.Texture = null;
            this.Position = Vector2.Zero;
            this.SourceRectangle = Rectangle.Empty;
            this.tint = Color.White;
            this.rotation = 0.0f;
            this.scale = 1.0f;
            this.spriteEffect = SpriteEffects.None;
            this.isVisible = true;
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="texture">Texture used to draw the Sprite.</param>
        /// <param name="position">Position in the world.</param>
        /// <param name="sourceRectangle">
        /// Location of current frame on the source texture.
        /// </param>
        /// <param name="tint">Color tint of the Sprite.</param>
        /// <param name="rotation">Rotation of the Sprite.</param>
        /// <param name="scale">Scale to draw the Sprite.</param>
        /// <param name="spriteEffect">Sprite flipping directions.</param>
        /// <param name="isVisible">Is the Sprite to be drawn?</param>
        public SpriteProperties(
            TextureReference texture,
            Vector2 position,
            Rectangle sourceRectangle,
            Color tint,
            float rotation,
            float scale,
            SpriteEffects spriteEffect,
            bool isVisible
            )
        {
            this.Texture = texture;
            this.Position = position;
            this.SourceRectangle = sourceRectangle;
            this.tint = tint;
            this.rotation = rotation;
            this.scale = scale;
            this.spriteEffect = spriteEffect;
            this.isVisible = isVisible;
        }
        #endregion

        #region Properties
        ///<summary>
        /// Texture used to draw the Sprite.
        /// </summary>
        [ImportAttribute] 
        public TextureReference Texture
        {
            get { return this.texture; }
            set { this.texture = value; }
        }
        /// <summary>
        /// Position in the world.
        /// </summary>
        [ImportAttribute] 
        public Vector2 Position
        {
            get { return this.position; }
            set { this.position = value; }
        }
        /// <summary>
        /// Location of current frame on the source texture.
        /// </summary>
        [ImportAttribute]
        public Rectangle SourceRectangle
        {
            get { return this.sourceRectangle; }
            set { this.sourceRectangle = value; }
        }
        /// <summary>
        /// Color tint of the Sprite.
        /// </summary>
        [ImportAttribute] 
        public Color Tint
        {
            get { return this.tint; }
            set { this.tint = value; }
        }
        /// <summary>
        /// Rotation of the Sprite.
        /// </summary>
        [ImportAttribute] 
        public float Rotation
        {
            get { return this.rotation; }
            set { this.rotation = value; }
        }
        /// <summary>
        /// Scale to draw the Sprite.
        /// </summary>
        [ImportAttribute] 
        public float Scale
        {
            get { return this.scale; }
            set { this.scale = value; }
        }
        /// <summary>
        /// Sprite flipping directions.
        /// </summary>
        [ImportAttribute] 
        public SpriteEffects SpriteEffect
        {
            get { return this.spriteEffect; }
            set { this.spriteEffect = value; }
        }
        /// <summary>
        /// Is the Sprite to be drawn?
        /// </summary>
        [ImportAttribute] 
        public bool IsVisible
        {
            get { return this.isVisible; }
            set { this.isVisible = value; }
        }
        #endregion

        #region IClonable Implementation
        /// <summary>
        /// Returns a cloned version of this object.
        /// </summary>
        /// <returns>Cloned version of this object.</returns>
        public object Clone()
        {
            return new SpriteProperties(
                this.Texture,
                this.Position,
                this.SourceRectangle,
                this.tint,
                this.rotation,
                this.scale,
                this.spriteEffect,
                this.isVisible
                );
        }
        #endregion
    }
}